<template>
  <div>
    <el-form :model="{}" size="medium" :inline="true" label-width="60px">
      <el-form-item label="操作栏" prop="">
        <el-button type="primary" plain icon="el-icon-plus" size="medium" @click="handleAdd"
          v-hasPermi="['ledger_reuse_add']">添加设备</el-button>
      </el-form-item>
      <el-form-item label="" prop="" v-show="displayflag === 1">
        <el-button v-hasPermi="['ledger_reuse_Check']" type="success" plain icon="el-icon-search" size="medium"
          @click="handleUpdate">查看价格</el-button>
      </el-form-item>
      <el-form-item label="" prop="" v-show="displayflag === 0">
        <el-button v-hasPermi="['ledger_reuse_Check']" type="warning" plain icon="el-icon-search" size="medium"
          @click="handleUpdate">隐藏价格</el-button>
      </el-form-item>
      <el-form-item label="" prop="">
        <el-button type="primary" plain icon="el-icon-download" size="medium" @click="handleload">导出台账列表</el-button>
      </el-form-item>
    </el-form>
    <template v-if="open">
      <AddbaseValue :title="title"></AddbaseValue>
    </template>
  </div>
</template>

<script>
import { downloadequipment } from "@/api/equipment/equipment.js";

export default {
  name: 'reuse',
  components: {
    AddbaseValue: () => import('../form/addbaseValue.vue')
  },
  data () {
    return {
      title: '新增设备台账',
      open: false
    }
  },
  computed: {
    displayflag () {
      return this.$store.state.reuseVariable.PriceDisplay
    }
  },
  methods: {
    /** 新增按钮操作 */
    handleAdd () {
      this.open = true
    },
    /** 修改按钮操作 */
    handleUpdate () {
      if (this.displayflag === 0) {
        this.$store.commit("UPDATE_PRICE", 1)//修改显示隐藏
      } else {
        this.$store.commit("UPDATE_PRICE", 0)
      }
      this.$emit('selectList')
    },
    /** 删除按钮操作 */
    handleDelete (row) {

    },
    /**下载 */
    handleload () {
      let params = {}
      let name = '台账信息列表.xlsx'
      downloadequipment(params, name).then(res => {
        console.log(res);
      }).catch(err => {
        console.log(err);
      })
    },
  }
}
</script>

<style>
</style>